package com.example.demo.security.controller;

import com.example.demo.security.entity.SysUser;
import com.example.demo.security.service.ILoginService;
import com.example.demo.utils.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * ******************************************************
 *
 * @author liugh9
 * @version 1.0
 * @classname LoginController
 * @description
 * @date 2024/03/28 22:16
 * <p>
 * ******************************************************
 */
@RestController("securityLoginController")
public class LoginController {

    @Autowired
    private ILoginService loginServcie;

    @PostMapping("/user/login")
    public ResponseData login(@RequestBody SysUser user) {
        return ResponseData.success(loginServcie.login(user));
    }

    @GetMapping("/user/logout")
    public ResponseData logout() {
        loginServcie.logout();
        return ResponseData.success("注销成功");
    }
}
